import logging
import os
import sys

if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
    from app_config import workspace_base
    fmt = '%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s'
    file_name = os.path.join(workspace_base, 'BLE debug tool.log')
    logging.debug('running in a PyInstaller bundle')

    logging.basicConfig(
        level=logging.DEBUG,
        format=fmt,
        datefmt='%a, %d %b %Y %H:%M:%S',
        filename=file_name,
        filemode='w'
    )
else:
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
    )
    logging.info('running in a normal Python process')